/*
 * Copyright 2007 The semap project development team.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Created by myn at 29.08.2007 15:03:34.
 *
 * This class is a handler of the REMOVE command.
 *
 * $Id: RemoveCmdProc.java 440 2007-08-29 19:25:17Z Mike.Navern $
 */
package com.google.code.contactserv;

import java.io.IOException;
import java.util.List;

import com.google.code.contactserv.model.PropertyHolder;
import com.google.code.contactserv.service.ContactService;

/**
 * @author myn
 *
 */
public class RemoveCmdProc extends CommandProcessor {

    /**
     * @param srv
     * @param line
     */
    public RemoveCmdProc(ContactService srv, List<PropertyHolder> lst) {
        super(srv, lst);
    }

    /* (non-Javadoc)
     * @see com.google.code.contactserv.CommandProcessor#doWork(java.lang.String)
     */
    @Override
    public void doWork(String uri) {
        System.out.print("Are you sure you want to delete those contacts? (yes/no)");
        try {
			String str = readNext();
			if ((str.equalsIgnoreCase("y")) ||
				(str.equalsIgnoreCase("yes"))) {
		        srv.remove(uri);
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    }

}
